﻿using JiGBot.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;

namespace JiGBot
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        #region Variables Constructor
        public DataLoader Script;
        public Util util;
        public MainWindow()
        {
            InitializeComponent();
            Script = new DataLoader();
            util = new Util(Util.GetFirstClient());
            SP.Children.RemoveRange(0, 10);
            SP2.Children.RemoveRange(0, 25);
            foreach (Control C in DataLoader.HealerControls)
            {
                SP2.Children.Add(C);
            }
            SP.Children.Add(DataLoader.HealerDS);
            DataTypeDisplay.SelectedIndex = 0;
        }
        #endregion

        #region MenuItems
        
        private void MenuExit(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void Window_Closing_1(object sender, CancelEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void SelectClient(object sender, RoutedEventArgs e)
        {
            util.ChooseClient();
        }

        private void MenuSave(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = "Script.xml";
            dlg.DefaultExt = ".xml";
            dlg.Filter = "XML Documents (.xml)|*.xml";
            if (dlg.ShowDialog() == true)
            {
                Script.SaveTree(dlg.FileName);
            }
        }

        private void MenuLoad(object sender, RoutedEventArgs e)
        {
            Script.LoadTree();
        }

        private void EnableHealClick(object sender, RoutedEventArgs e)
        {
            if (EnableHeal.IsChecked)
            {
                Healer.Start();
            }
            else
            {
                Healer.Stop();
            }
        }

        private void EnableWalkerClick(object sender, RoutedEventArgs e)
        {
            
        }

        private void EnableTargetingClick(object sender, RoutedEventArgs e)
        {

        }

        private void EnableHUDClick(object sender, RoutedEventArgs e)
        {

        }

        private void EnableLootingClick(object sender, RoutedEventArgs e)
        {

        }

        private void EnableHotkeysClick(object sender, RoutedEventArgs e)
        {

        }

        #endregion

        #region Switch DataGrid Viewer

        private void tvHealerSelect(object sender, RoutedEventArgs e)
        {
            SP.Children.RemoveRange(0, 10);
            SP2.Children.RemoveRange(0, 25);
            foreach (Control C in DataLoader.HealerControls)
            {
                SP2.Children.Add(C);
            }
            SP.Children.Add(DataLoader.HealerDS);
        }

        private void tvWalkerSelect(object sender, RoutedEventArgs e)
        {
            SP.Children.RemoveRange(0, 10);
            SP2.Children.RemoveRange(0, 25);
            foreach (Control C in DataLoader.WaypointsControls)
            {
                SP2.Children.Add(C);
            }
            SP.Children.Add(DataLoader.WaypointsDS);
        }

        private void tvTargetingSelect(object sender, RoutedEventArgs e)
        {
            SP.Children.RemoveRange(0, 10);
            SP2.Children.RemoveRange(0, 25);
            foreach (Control C in DataLoader.TargetingControls)
            {
                SP2.Children.Add(C);
            }
            SP.Children.Add(DataLoader.TargetingDS);
        }

        private void tvLootingSelect(object sender, RoutedEventArgs e)
        {
            SP.Children.RemoveRange(0, 10);
            SP2.Children.RemoveRange(0, 25);
            foreach (Control C in DataLoader.LootingControls)
            {
                SP2.Children.Add(C);
            }
            SP.Children.Add(DataLoader.LootingDS);
        }

        private void tvHotkeysSelect(object sender, RoutedEventArgs e)
        {
            SP.Children.RemoveRange(0, 10);
            SP2.Children.RemoveRange(0, 25);
            foreach (Control C in DataLoader.HotkeysControls)
            {
                SP2.Children.Add(C);
            }
            SP.Children.Add(DataLoader.HotkeysDS);
        }

        private void tvHudSelect(object sender, RoutedEventArgs e)
        {
            SP.Children.RemoveRange(0, 10);
            SP2.Children.RemoveRange(0, 25);
            foreach (Control C in DataLoader.HUDControls)
            {
                SP2.Children.Add(C);
            }
            SP.Children.Add(DataLoader.HUDDS);
        }

        #endregion
    }
}
